package com.app.mapper;

import com.app.model.VerificationRecordModel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 商家核销记录表
 *
 * @author 16693103420
 * @since 2024-01-31
 */
@Mapper
public interface VerificationRecordMapper extends BaseMapper<VerificationRecordModel> {

    //累计消费
//    @Select("select sum(v.pay_amount) from " +
//            "tb_verification_record v,tb_order o " +
//            "where  v.user_id=#{userId}")
    Double userSumConsume(@Param("userId") Integer userId);

    //今日消费
//    @Select("select sum(o.voucher) " +
//            "from tb_verification_record v,tb_order o " +
//            "where DATE_FORMAT(v.create_time,\"%Y-%m-%d %H:%i:%s\") " +
//            "BETWEEN #{beginTime} and #{endTime} " +
//            "and v.user_id=#{userId}")
    Double userTodayConsume(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("userId") Integer userId);

    double contribution_points_earned_by_individuals(@Param("userId") Integer userId);
    //用户累计贡献积分
    @Select("select sum(contribute_integral) from tb_verification_record where user_id =#{userId}")
    Double sumContributeIntegral(@Param("userId") Integer userId);
}
